﻿#define _CRT_SECURE_NO_WARNINGS 1
#pragma once
#include<stdio.h>
#include<stdlib.h>
#include<windows.h>
#include<stdbool.h>
#include<locale.h>
#include<time.h>
#define POS_X 24
#define POS_Y 5
#define BODY1 L'○'
#define BODY2 L'■'
#define FOOD L'★'
#define WALL L'※'
#define KEY_PRESS(VK) ((GetAsyncKeyState(VK) & 0x1) ? 1 : 0)
//类型声明
//蛇身节点
typedef struct SnakeNode
{
	int x;
	int y;
	struct SnakeNode* next;
}SnakeNode, *pSnakeNode;

//蛇的方向
enum DIRECTION
{
	UP = 1,
	DOWN,
	LEFT,
	RIGHT
};

//游戏状态
enum GAME_STATUS
{
	OK,//正常运行
	KILL_BY_WALL,//撞墙
	KILL_BY_SELF,//咬死自己
	END_NOMAL//正常退出
};

//贪吃蛇
typedef struct Snake
{
	pSnakeNode _pSnake;//指向蛇头的指针
	pSnakeNode _pFood;//食物指针
	enum DIRECTION _Dir;//蛇头的方向
	enum STATUS _Status;//游戏状态
	int _Score;//得分
	int _foodWeight;//食物分数
	int _SleepTime;//每走一步休息时间
}Snake, *pSnake;

//函数声明
void GameStart(pSnake ps);
void GameRun(pSnake ps);
void GameEnd(pSnake ps);
void SetPos(int x, int y);
